package com.eningqu.aipen;

import android.annotation.SuppressLint;

import com.eningqu.aipen.logic.model.ResponseBean;
import com.eningqu.aipen.logic.model.medical.MedicalBean;
import com.eningqu.aipen.logic.network.Apis;
import com.eningqu.aipen.logic.network.BaseRetrofitUtils;
import com.kongzue.dialogx.dialogs.PopTip;

import java.io.File;
import java.text.SimpleDateFormat;
import java.util.Date;

import io.reactivex.ObservableSource;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.functions.Consumer;
import io.reactivex.functions.Function;
import io.reactivex.schedulers.Schedulers;
import okhttp3.MediaType;
import okhttp3.MultipartBody;
import okhttp3.RequestBody;

/**
 * Package:com.eningqu.aipen
 * Author:starr
 * Time:2023/11/20 19:30
 * Description:
 */
public class Main {
    public static void main(String[] args) {
        @SuppressLint("SimpleDateFormat") SimpleDateFormat spf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        System.out.println(spf.format(new Date()));

        BaseRetrofitUtils.getInstance().create(Apis.class).getMedicalByIdRx(4)
                .subscribeOn(Schedulers.io())
                .flatMap(new Function<MedicalBean, ObservableSource<ResponseBean>>() {
                    @Override
                    public ObservableSource<ResponseBean> apply(MedicalBean medicalBean) throws Exception {
                        medicalBean.bl.blState = true;
                        @SuppressLint("SimpleDateFormat") SimpleDateFormat spf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
                        medicalBean.bl.blUpdateTime = spf.format(new Date());
                        System.out.println(Thread.currentThread());
                        return BaseRetrofitUtils.getInstance().create(Apis.class).updateMedicalRx(medicalBean.bl);
                    }
                })
                .subscribeOn(AndroidSchedulers.mainThread())
                .subscribe(new Consumer<ResponseBean>() {
                    @Override
                    public void accept(ResponseBean responseBean) throws Exception {
                        System.out.println(Thread.currentThread());
                    }
                });
    }


}
